package cn.wolfcode.ssm.service.impl;

import cn.wolfcode.ssm.domain.Classinfo;
import cn.wolfcode.ssm.mapper.ClassinfoMapper;
import cn.wolfcode.ssm.qo.QueryObject;
import cn.wolfcode.ssm.service.IClassinfoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassinfoServiceImpl implements IClassinfoService {

    @Autowired
    private ClassinfoMapper classinfoMapper;
    @Override
    public void delete(Long id) {
        classinfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void save(Classinfo classinfo) {
        classinfoMapper.insert(classinfo);
    }

    @Override
    public Classinfo getOne(Long id) {
        return classinfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Classinfo> getAll() {
        return classinfoMapper.selectAll();
    }

    @Override
    public void update(Classinfo classinfo) {
        classinfoMapper.updateByPrimaryKey(classinfo);
    }


    @Override
    public PageInfo<Classinfo> selctForPageResult(QueryObject qo) {
        //使用分页插件,传入当前页,每页显示数量
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Classinfo> classinfos = classinfoMapper.selectForResult(qo);
        return new PageInfo(classinfos);
    }
}
